package top.yangguangmc.smart_scheduling.checks;

import java.util.Objects;

public class TableProblem {
    private final TableProblemType type;
    private final String message;
    private final int cellX;
    private final int cellY;
    private final TableProblemDomain domain;

    public TableProblem(TableProblemType type, String message, int cellX, int cellY, TableProblemDomain domain) {
        this.message = message;
        this.cellX = cellX;
        this.cellY = cellY;
        this.type = type;
        this.domain = domain;
    }

    public TableProblemType getType() {
        return type;
    }

    public String getMessage() {
        return message;
    }

    public int getCellX() {
        return cellX;
    }

    public int getCellY() {
        return cellY;
    }

    public String getCellPosAsString() {
        return "(" + cellX + ", " + cellY + ")";
    }

    public TableProblemDomain getDomain() {
        return domain;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        TableProblem that = (TableProblem) object;
        return cellX == that.cellX && cellY == that.cellY && type == that.type;
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, cellX, cellY);
    }

    @Override
    public String toString() {
        return getCellPosAsString() + ": " + message;
    }
}
